/*     */ package com.lmpop.trade.ti_teamorder;
/*     */ 
/*     */ import com.lmpop.frame.QueryList;
/*     */ import com.lmpop.frame.SysMap;
/*     */ import com.lmpop.frame.TradeInterf;
/*     */ import com.lmpop.frame.dao.DbmInterf;
/*     */ import com.lmpop.frame.dao.IbatisDbmImpl;
/*     */ import com.lmpop.frame.exp.ApplicationException;
/*     */ import java.util.Hashtable;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.Random;
/*     */ 
/*     */ public class Ti_groupVoucherInfo
/*     */   implements TradeInterf
/*     */ {
/*     */   QueryList queryList;
/*     */ 
/*     */   public Ti_groupVoucherInfo()
/*     */   {
/*  20 */     this.queryList = new QueryList();
/*     */   }
/*     */ 
/*     */   public void insertTi_groupVoucher(Map map) {
/*  24 */     int num = Integer.parseInt(map.get("num").toString());
/*  25 */     DbmInterf dbmMgr = new IbatisDbmImpl();
/*     */ 
/*  27 */     String content = "";
/*  28 */     for (int i = 0; i < num; i++) {
/*  29 */       Ti_groupVoucher ti_groupVoucher = new Ti_groupVoucher();
/*  30 */       ti_groupVoucher.setOrder_no(map.get("order_no").toString());
/*  31 */       ti_groupVoucher.setInfo_id(map.get("info_id").toString());
/*  32 */       ti_groupVoucher.setUser_id(map.get("user_id").toString());
/*  33 */       ti_groupVoucher.setCompany_id(map.get("company_id").toString());
/*  34 */       ti_groupVoucher.setEnabled("1");
/*  35 */       ti_groupVoucher.setVoucher_code(randCode(5));
/*  36 */       ti_groupVoucher.setVoucher_pwd(randCode(5));
/*  37 */       if (map.get("tip") != null) {
/*  38 */         ti_groupVoucher.setTip(map.get("tip").toString());
/*     */       }
/*     */       try
/*     */       {
/*  42 */         dbmMgr.update("insertTi_groupVoucher", ti_groupVoucher);
/*     */       } catch (ApplicationException e) {
/*  44 */         e.printStackTrace();
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   public Map checkTeamOrderType(String order_no)
/*     */   {
/*  55 */     List list = this.queryList.getList("checkTeamOrderType", order_no);
/*  56 */     if ((list != null) && (list.size() > 0)) {
/*  57 */       return (Map)list.get(0);
/*     */     }
/*  59 */     return null;
/*     */   }
/*     */ 
/*     */   public void insert(DbmInterf dbmMgr, Ti_groupVoucher ti_groupVoucher) throws ApplicationException {
/*     */   }
/*     */ 
/*     */   public SysMap delete(DbmInterf dbmMgr, SysMap map) {
/*  66 */     return null;
/*     */   }
/*     */ 
/*     */   public List getListByPk(String id) {
/*  70 */     return null;
/*     */   }
/*     */ 
/*     */   public SysMap insert(DbmInterf dbmMgr, SysMap map) {
/*  74 */     return null;
/*     */   }
/*     */ 
/*     */   public SysMap update(DbmInterf dbmMgr, SysMap map)
/*     */   {
/*  79 */     String result_code = "0";
/*  80 */     Ti_groupVoucher ti_groupVoucher = new Ti_groupVoucher();
/*  81 */     ti_groupVoucher.setVoucher_code(map.getString("voucher_code"));
/*  82 */     ti_groupVoucher.setVoucher_pwd(map.getString("voucher_pwd"));
/*  83 */     ti_groupVoucher.setEnabled(map.getString("enabled"));
/*     */     try {
/*  85 */       update(dbmMgr, ti_groupVoucher);
/*     */     } catch (Exception e) {
/*  87 */       e.printStackTrace();
/*  88 */       result_code = "1";
/*     */     }
/*  90 */     map.setString("result_code", result_code);
/*  91 */     return map;
/*     */   }
/*     */ 
/*     */   public void update(DbmInterf dbmMgr, Ti_groupVoucher ti_groupVoucher) throws ApplicationException {
/*  95 */     dbmMgr.update("updategroupVoucherStateByOrderNo", ti_groupVoucher);
/*     */   }
/*     */ 
/*     */   public List getListByPage(Object obj, int start, int limit) {
/*  99 */     Hashtable ti_groupvoucher = (Hashtable)obj;
/* 100 */     if (start == 0)
/* 101 */       start = 0;
/*     */     else {
/* 103 */       start = (start - 1) * limit;
/*     */     }
/* 105 */     ti_groupvoucher.put("start", Integer.valueOf(start));
/* 106 */     ti_groupvoucher.put("limit", Integer.valueOf(limit));
/* 107 */     return this.queryList.getList("getListByTi_groupVoucherPage", ti_groupvoucher);
/*     */   }
/*     */ 
/*     */   public int getCountByObj(Object obj) {
/* 111 */     Hashtable ti_groupvoucher = (Hashtable)obj;
/* 112 */     List list = this.queryList.getList("getCountByObjTi_groupVoucher", ti_groupvoucher);
/* 113 */     int count = 0;
/* 114 */     if ((list != null) && (list.size() > 0)) {
/* 115 */       Hashtable newsMap = (Hashtable)list.get(0);
/* 116 */       if ((newsMap.get("count") != null) && (!newsMap.get("count").toString().equals(""))) {
/* 117 */         count = Integer.parseInt(newsMap.get("count").toString());
/*     */       }
/*     */     }
/* 120 */     return count;
/*     */   }
/*     */ 
/*     */   private static String randCode(int len) {
/* 124 */     StringBuffer buf = new StringBuffer();
/* 125 */     Random rand = new Random();
/* 126 */     for (int i = 0; i < len; i++) {
/* 127 */       buf.append(rand.nextInt(100));
/*     */     }
/* 129 */     return buf.toString();
/*     */   }
/*     */ 
/*     */   public int updateStateByCode(String code, String pwd, String order_no, String enabled) {
/* 133 */     DbmInterf dbmMgr = new IbatisDbmImpl();
/* 134 */     Ti_groupVoucher ti_groupVoucher = new Ti_groupVoucher();
/* 135 */     ti_groupVoucher.setVoucher_code(code);
/* 136 */     ti_groupVoucher.setVoucher_pwd(pwd);
/* 137 */     ti_groupVoucher.setEnabled(enabled);
/*     */     try
/*     */     {
/* 140 */       update(dbmMgr, ti_groupVoucher);
/* 141 */       if (enabled.equals("2"))
/* 142 */         dbmMgr.update("alterUse_moneyByGroupVoucher", order_no);
/* 143 */       if (enabled.equals("1"))
/* 144 */         dbmMgr.update("alterUse_moneyByEnabled", order_no);
/*     */     } catch (Exception e) {
/* 146 */       e.printStackTrace();
/* 147 */       return 0;
/*     */     }
/* 149 */     return 1;
/*     */   }
/*     */ }

/* Location:           F:\电商\commons-utils.jar
 * Qualified Name:     com.lmpop.trade.ti_teamorder.Ti_groupVoucherInfo
 * JD-Core Version:    0.6.0
 */